home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / dsp / dspgroup / macrosrc.arc / DDV.ASM < prev    next >
Encoding:
Assembly Source File  |  1983-11-17  |  1.7 KB  |  52 lines

  1.  
  2.      UNL
  3.      COPY MACROS.FUNC
  4.      COPY MACROS.PROG
  5.      COPY MACROS.STOP
  6.      COPY MACROS.LDAX
  7.      COPY MACROS.SACX
  8.      COPY MACROS.SUBX
  9.      COPY MACROS.VAR
  10.      LIST
  11.  
  12.      FUNC DDV$,(DIVID,2),DIVSOR,QUOTNT,REMAIN  Begin FUNC 
  13.      VAR  QSN,SAVE1    Declare temporaries
  14.      SAR  AR1,SAVE1     Save the AR used in our loop
  15.      LAC  DIVID,0    Test Dividend
  16.      BLZ  S2        Skip if negative
  17.      LAC  ONE,0         Pick up sign of remainder
  18.      SACL QSN,0         Save the sign
  19.      LAC  DIVSOR,0      Test Divisor
  20.      BGEZ S3        Skip if positive
  21. S1   LT      MINUS      Pick up sign of quotient
  22.      B    S4            Go divide
  23. S2   LAC  MINUS,0       Pick up sign of remainder
  24.      SACL QSN,0         Save the sign
  25.      ZAC                Load 0
  26.      SUBX DIVID        Compute -DIVID
  27.      SACX DIVID         Save -DIVID
  28.      LAC  DIVSOR,0      Test Divisor
  29.      BGEZ S1        Skip if negative
  30. S3   LT   ONE           Pick up sign of quotient
  31. S4   ZAC        Load 0
  32.      SUB  DIVSOR,0      Make -DIVSOR
  33.      BLZ  S5        Skip if made it minus
  34.      SACL DIVSOR,0      Save -DIVSOR (which is positive)
  35. S5   LDAX DIVID        Load absolute value of dividend
  36.      LARK AR1,15    Load shift count-1
  37.      LARP AR1        Select AR1
  38. LOOP SUBC DIVSOR    One Shift left and subtract
  39.      BANZ LOOP        loop for 16 times
  40.      SACL QUOTNT,0      Save Unsigned quotient
  41.      SACH REMAIN,0      Save Unsigned remainder
  42.      MPY  QUOTNT    Compute Signed Quotient
  43.      PAC        To AC
  44.      SACL QUOTNT,0      To QUOTNT
  45.      LT   QSN           Load the sign
  46.      MPY  REMAIN        Compute signed remainder
  47.      PAC        To AC
  48.      SACL REMAIN,0      To REMAIN
  49.      LAR  AR1,SAVE1     Restore AR1
  50.      STOP            Return
  51.  
  52.      END